package study.domain.user;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 권한 ID
 *
 * @author Barney Kim
 */
@Embeddable
@Data
@EqualsAndHashCode
public class AuthorityId implements Serializable {

	private static final long serialVersionUID = -6631573663298462334L;

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "user_id", nullable = false, updatable = false)
	@org.hibernate.annotations.ForeignKey(name = "fk_authorities_user_id")
	private User user;

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "role", nullable = false, updatable = false)
	@org.hibernate.annotations.ForeignKey(name = "fk_authorities_role")
	private Role role;

	public AuthorityId() {
	}

	public AuthorityId(User user, Role role) {
		this.user = user;
		this.role = role;
	}
}
